﻿//==============================================================================
//author:  UnKnow
//Create Data:  UnKnow
//Description: BllPayAndReceiveItemFactory [Get And Rewrite by Zeinali,Farshad]
//Email: farshadz70@gmail.com
//Mobile: 0912_6467348
//LastUpdate: 1390/02/24 00:35
//Important:Lotfan kasi bedon hamahangi man Class ro taghir nade
//==============================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ChequeManagement.BLL
{
    /// <summary>
    /// This Class Includes Field, constructor, Method that Inheritance of "BaseFactory" Class
    /// </summary>
    /// <Method>this class includes some method for add,edit,getall,remove data</Method>
    public class BLLPayAndRecieveItemFactory : BaseFactory
    {


        #region Methods
        /// <summary>
        /// This constructor called base constructor and set parameter that parameter value is "PayAndReceiveItem"
        /// and use on create instance of class
        /// </summary>
        public BLLPayAndRecieveItemFactory()
            : base("PayAndReceiveItem")
        {

        }

        private DAL.DALPayAndReceiveItem objDALPayAndReceiveItem = new DAL.DALPayAndReceiveItem();
        /// <summary>
        /// This method get a object that type is BLL.BLLPayAndReceiveItem 
        /// create a instance of DAL.DALPayAndReceiveItem class and call Insert method and set parameter
        /// </summary>
        /// <param name="PayAndRecieveItemObj" Type="BLL.BLLPayAndReceiveItem"></param>
        public void Add(BLL.BLLPayAndReceiveItem PayAndRecieveItemObj)
        {
            try
            {

                objDALPayAndReceiveItem.Insert(PayAndRecieveItemObj);
            }
            catch (SqlException ex)
            {

                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// This method get a object that type is BLL.BLLPayAndReceiveItem and a object that type is int
        /// this method call objDALPayAndReceiveItem that type is BLL.BLLPayAndReceiveItem and call Update method and set parameter 
        /// </summary>
        /// <param name="PayAndRecieveItemObj" Type="BLL.BLLPayAndReceiveItem"></param>
        /// <param name="targetChequeNo" Type="int"></param>
        /// <return>this type is void and Do not return</return>
        public void Edit(BLL.BLLPayAndReceiveItem PayAndRecieveItemObj, int targetChequeNo)
        {
            try
            {

                objDALPayAndReceiveItem.Update(PayAndRecieveItemObj, targetChequeNo);
            }
            catch (SqlException ex)
            {

                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// This method not have parameter
        /// and call objDALPayAndReceiveItem that type is BLL.BLLPayAndReceiveItem and call FetchAll method for select all data
        /// </summary>
        /// <returns>this method select data and result return into DataTable</returns>
        public void GetAll(DataTable DT)
        {

            try
            {
                //DataTable DT = new DataTable();

                objDALPayAndReceiveItem.FetchAll(DT);
                
            }
            catch (SqlException ex)
            {

                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// This method not have parameter
        /// and call objDALPayAndReceiveItem that type is BLL.BLLPayAndReceiveItem and call FetchAll method for select all data
        /// </summary>
        /// <returns>this method select all data and result return into List<> that type is BLLPayAndReceiveItem</returns>
        public List<BLLPayAndReceiveItem> GetAll()
        {
            try
            {
                List<BLL.BLLPayAndReceiveItem> li = new List<BLLPayAndReceiveItem>();
                li = objDALPayAndReceiveItem.FetchAll();
                return li;
            }
            catch (SqlException ex)
            {

                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// This method have parameters
        /// and call objDALPayAndReceiveItem that type is BLL.BLLPayAndReceiveItem and call FetchByField method and set parameters
        /// the filedname parameter select field name on select table and vlaue parameter select value that select field name
        /// </summary>
        /// <param name="fieldName" Type="string"></param>
        /// <param name="value" Type="object"></param>
        /// <returns>this method select data and result return into List<> that type is BLLPayAndReceiveItem</returns>
        public List<BLLPayAndReceiveItem> GetByField(ChequeManagement.BLL.BLLPayAndReceiveItem.PayAndReceiveItemField fieldName, object value)
        {
            try
            {
                List<BLL.BLLPayAndReceiveItem> li = new List<BLLPayAndReceiveItem>();
                li = objDALPayAndReceiveItem.FetchByField(fieldName, value);
                return li;
            }
            catch (SqlException ex)
            {

                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        /// <summary>
        /// This method have parameters
        /// and call objDALPayAndReceiveItem that type is BLL.BLLPayAndReceiveItem and call FetchByField method and set parameters
        /// the filedname parameter select field name on select table and vlaue parameter select value that select field name and result return into dt parameter
        /// </summary>
        /// <param name="fieldName" Type="string"></param>
        /// <param name="value" Type="object"></param>
        /// <param name="dt" Type="DataTable"></param>
        /// <return>this type is void and Do not return but parameter is DataTable and result return into this DataTable</return>
        public void GetByField(ChequeManagement.BLL.BLLPayAndReceiveItem.PayAndReceiveItemField fieldName, object value, DataTable dt)
        {
            try
            {

                objDALPayAndReceiveItem.FetchByField(fieldName, value, dt);
            }
            catch (SqlException ex)
            {

                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// This method have parameter
        /// and call objDALPayAndReceiveItem that type is BLL.BLLPayAndReceiveItem and call FetchByKey method and set parameters
        /// select data by targetChequeNo
        /// </summary>
        /// <param name="targetChequeNo" Type="int"></param>
        /// <returns>object that type is BLLPayAndReceiveItem</returns>
        public BLLPayAndReceiveItem GetByKey(int targetChequeNo)
        {
            BLL.BLLPayAndReceiveItem BLLPayAndReceiveItemObject = new BLLPayAndReceiveItem();

            try
            {
                BLLPayAndReceiveItemObject = objDALPayAndReceiveItem.FetchByKey(targetChequeNo);
                return BLLPayAndReceiveItemObject;
            }
            catch (SqlException ex)
            {

                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }


        }

        /// <summary>
        /// This method have parameter
        /// and call objDALPayAndReceiveItem that type is BLL.BLLPayAndReceiveItem and call FetchAllByCondition method and set parameters
        /// select data by Condition
        /// </summary>
        /// <param name="Condition" Type="string"></param>
        /// <param name="dataTable" Type="DataTable"></param>
        public void GetAllByCondition(string Condition, DataTable dataTable)
        {
            try
            {
                objDALPayAndReceiveItem.FetchAllByCondition(Condition, dataTable);
            }
            catch (SqlException ex)
            {
                
                throw ex;
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
        
        /// <summary>
        /// This method have parameter
        /// and call objDALPayAndReceiveItem that type is BLL.BLLPayAndReceiveItem and call Delete method and set parameters
        /// </summary>
        /// <param name="targetChequeNo" Type="int"></param>
        /// <return>this type is void and Do not return</return>
        public void Remove(int targetChequeNo)
        {
            try
            {

                objDALPayAndReceiveItem.Delete(targetChequeNo);
            }
            catch (SqlException ex)
            {

                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// This method have parameter
        /// and call objDALPayAndReceiveItem that type is BLL.BLLPayAndReceiveItem and call Delete method and set parameters
        /// remove field from table by this fieldName that value is this value
        /// </summary>
        /// <param name="fieldname" Type="string"></param>
        /// <param name="value" Type="object"></param>
        /// <return>this type is void and Do not return</return>
        public void Remove(ChequeManagement.BLL.BLLPayAndReceiveItem.PayAndReceiveItemField fieldname, object value)
        {
            try
            {

                //objDALPayAndReceiveItem.Delete(fieldname, value);
            }
            catch (SqlException ex)
            {

                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion


    }
}





